home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000106_icon-group-sender _Thu Oct 30 08:36:03 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
5KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id IAA25711
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Thu, 30 Oct 1997 08:36:03 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA28663; Thu, 30 Oct 1997 08:36:02 -0700
To: icon-group@optima.CS.Arizona.EDU
Date: Thu, 30 Oct 1997 16:27:31 +1000
From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
Message-Id: <Stuart.Robinson-3010971627320001@asianstmg-229.anu.edu.au>
Organization: ANU
Sender: icon-group-request@optima.CS.Arizona.EDU
Subject: problem with data type in program
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Hello, everyone. I wanted to apologise for causing a stir with my last
couple of postings. It has been brought to my attention that they gave
the impression of not only an unwillingnes to actually learn Icon but also
ingratitude towards those who have helped me in the past. This is not the
impression that I wish to give the readers of this newsgroup, because I am
keen to learn to program well in Icon and I sincerely appreciate all of
the help that I have received thus far.
With that said, I would like to solicit help with a program that is
causing me problems. It is, I think, less trivial than my query about
tabulating values (which was admittedly trivial and should not have been
posted in the first place).
The problem is this. I am getting error messages saying that the main
procedure expects a table does not get one from the procedure it
invokes--namely, scantext(). But it looks to me as if the value returned
by scantext() should be a table. What am I doing wrong?
Thanks in advance for any help.
Regards,
Stuart Robinson
############################################################################
#
# File: tabulate_AO_person.icn
# Subject: Program to tabulate person of A and O
# Author: Stuart P. Robinson
# Date: 14 October, 1997
#
############################################################################
#
# This program was written to calculate what proportion of A's and O's
# are 1st, 2nd, or 3rd person. Unlike previous version, it does NOT give
# percentages--just raw numbers. The 7 logical possibilities it counts are:
#
# 1. 1-2 first_on_second
# 2. 1-3 first_on_third
# 3. 2-1 second_on_first
# 4. 2-3 second_on_third
# 5. 3-1 third_on_first
# 6. 3-2 third_on_second
# 7. 3-3 third_on_third
#
############################################################################
procedure main()
output := sort( scan_text(), 1 )
write( "Person Config." || "/t" || "No." )
every x := key( output ) do
write( x || "\t" || output[x] )
end
procedure scan_text( )
value_table := table( 0 )
while line := read()
do
{
line ?
{
value_table[ search_line() ] +:= 1
}
}
return value_table
end
procedure search_line( )
chars := &letters++&digits++'{`'
subject := 0
object := 0
if find( "{Q" ) then
while tab( upto( chars ) ) do
{
word := tab( many( chars ) )
word ?
{
if tab( find( "{" ) ) then
word := tab( 0 )
case word of
{
"{A1" : subject := 1
"{A2" : subject := 2
"{A" : subject := 3
"{O1" : object := 1
"{O2" : object := 2
"{O" : object := 3
}
}
}
if subject == 1 then
if object == 2 then type := "first on second"
else if object == 3 then type := "first on third"
if subject == 2 then
if object == 1 then type := "second on first"
else if object == 3 then type := "second on third"
if subject == 3 then
if object == 1 then type := "third on first"
else if object == 2 then type := "third on second"
else if object == 3 then type := "third on third"
return type
end
--
Stuart Robinson <Stuart.Robinson@nospam.anu.edu.au>
The Australian National University
*TO REPLY, REMOVE "nospam." FROM E-MAIL ADDRESS GIVEN ABOVE